home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_100
/
146_01
/
fsize.txt
< prev
next >
Wrap
Text File
|
1985-03-09
|
3KB
|
146 lines
NAM BINARY FILE SIZE ANALYZER
OPT PAG
* This routine reads a binary file and prints the
* load addresses of the file, as well as transfer
* address(es), if any.
* Usage:
* +++FSIZE,Filename[.CMD]
* --- FLEX POINTERS ---
WARMS EQU $AD03 DOS RE-ENTRY
GETFIL EQU $AD2D GET FILE SPEC
SETEXT EQU $AD33 SET DEFAULT EXTENSION
RPTERR EQU $AD3F REPORT ERROR
PSTRNG EQU $AD1E PRINT STRING
ADDBX EQU $AD36 ADD B REG TO X REG
OUTADR EQU $AD45 OUTPUT HEX ADDRESS
PUTCHR EQU $AD18 PRINT CHARACTER
FMS EQU $B406
FMSCLS EQU $B403
FCB EQU $A840
ORG $A100
FSIZE BRA FSZ1
FCB 1 VERSION NUMBER
FSZ1 LDX #FCB POINT TO FCB
JSR GETFIL GET FILE SPEC
BCC FSZOK IF NO ERRORS BRANCH AROUND
FSZ11 JMP FSZERR
FSZOK LDA A #1 SET UP CODE
STA A 0,X FOR READ OPEN
INC A
JSR SETEXT SET .CMD EXTENSION
JSR FMS CALL FMS - DO OPEN
BNE FSZ11
LDA A #$FF
STA A 59,X SET NO COMPRESS
FSZ2 LDX #FCB POINT TO FCB
JSR FMS CALL FMS - GET CHAR
BNE FSZTST ERROR ?
CMP A #$16 TRANSFER ADDRESS ?
BEQ FSZ5
CMP A #$02 START OF RECORD ?
BNE FSZ2
* OK, GET THE ADDRESS AND PRINT IT
BSR FADDR
BNE FSZERR
LDX #FMSG1
JSR PSTRNG PRINT MESSAGE
LDX #FTEMP POINT TO ADDRESS
JSR OUTADR AND PRINT IT
LDA B #4
LDX #FMSG3
FSZ3 LDA A 0,X
JSR PUTCHR PRINT CHAR
INX
DEC B
BNE FSZ3
LDX #FCB
JSR FMS GET SIZE OF RECORD
BNE FSZTST
STA A FCNT SAVE IT
TAB
DEC B ADJUST COUNT
LDX FTEMP GET ADDRESS
JSR ADDBX
STX FTEMP STORE END ADDRESS
LDX #FTEMP
JSR OUTADR PRINT END ADDRESS
FSZ4 LDX #FCB
JSR FMS GET CHAR
BNE FSZERR
DEC FCNT ALL DONE
BNE FSZ4
BRA FSZ2 GET NEXT RECORD
* GET TRANSFER ADDRESS AND PRINT IT.
FSZ5 BSR FADDR GET ADDRESS
BNE FSZERR
LDX #FMSG2
JSR PSTRNG PRINT MESSAGE
LDX #FTEMP
JSR OUTADR
BRA FSZ2 GET NEXT RECORD
* ------------
FSZTST LDA A 1,X GET ERROR STATUS
CMP A #8 IS IT EOF ?
BNE FSZERR
LDA A #4 CLOSE FILE CODE
STA A 0,X
JSR FMS CLOSE THE FILE
BNE FSZERR
JMP WARMS RETURN TO FLEX
FSZERR JSR RPTERR REPORT THE ERROR
JSR FMSCLS CLOSE ALL FILES
JMP WARMS
* -------------
* SUBROUTINE TO LOAD AN ADDRESS FROM THHE DISK FILE
FADDR LDX #FCB
JSR FMS GET ADDRESS MSB
BEQ FADDR1 SKIP IF NO ERRORS
RTS
FADDR1 STA A FTEMP
LDX #FCB
JSR FMS GET ADDRESS LSB
BEQ FADDR2
RTS
FADDR2 STA A FTEMP+1
CLR A SET ZERO BIT
RTS
* ------------
FTEMP RMB 2
FCNT RMB 1
FMSG1 FCC 'LOAD ADDRESS: '
FCB 4
FMSG2 FCC 'XFER ADDRESS: '
FCB 4
FMSG3 FCC ' TO '
END FSIZE